321 research outputs found

    Clarifying and compiling C/C++ concurrency: from C++11 to POWER

    Get PDF
    The upcoming C and C++ revised standards add concurrency to the languages, for the first time, in the form of a subtle *relaxed memory model* (the *C++11 model*). This aims to permit compiler optimisation and to accommodate the differing relaxed-memory behaviours of mainstream multiprocessors, combining simple semantics for most code with high-performance *low-level atomics* for concurrency libraries. In this paper, we first establish two simpler but provably equivalent models for C++11, one for the full language and another for the subset without consume operations. Subsetting further to the fragment without low-level atomics, we identify a subtlety arising from atomic initialisation and prove that, under an additional condition, the model is equivalent to sequential consistency for race-free programs

    Library abstraction for C/C++ concurrency

    Get PDF
    When constructing complex concurrent systems, abstraction is vital: programmers should be able to reason about concurrent libraries in terms of abstract specifications that hide the implementation details. Relaxed memory models present substantial challenges in this respect, as libraries need not provide sequentially consistent abstractions: to avoid unnecessary synchronisation, they may allow clients to observe relaxed memory effects, and library specifications must capture these. In this paper, we propose a criterion for sound library abstraction in the new C11 and C++11 concurrency model, generalising the standard sequentially consistent notion of linearizability. We prove that our criterion soundly captures all client-library interactions, both through call and return values, and through the subtle synchronisation effects arising from the memory model. To illustrate our approach, we verify implementations against specifications for the lock-free Treiber stack and a producer-consumer queue. Ours is the first approach to compositional reasoning for concurrent C11/C++11 programs. 1

    Synchronising C/C++ and POWER

    Get PDF
    Shared memory concurrency relies on synchronisation primitives: compare-and-swap, load-reserve/store-conditional (aka LL/SC), language-level mutexes, and so on. In a sequentially consistent setting, or even in the TSO setting of x86 and Sparc, these have well-understood semantics. But in the very relaxed settings of IBMÂŽ, POWERÂŽ, ARM, or C/C++, it remains surprisingly unclear exactly what the programmer can depend on. This paper studies relaxed-memory synchronisation. On the hardware side, we give a clear semantic characterisation of the load-reserve/store-conditional primitives as provided by POWER multiprocessors, for the first time since they were introduced 20 years ago; we cover their interaction with relaxed loads, stores, barriers, and dependencies. Our model, while not officially sanctioned by the vendor, is validated by extensive testing, comparing actual implementation behaviour against an oracle generated from the model, and by detailed discussion with IBM staff. We believe the ARM semantics to be similar. On the software side, we prove sound a proposed compilation scheme of the C/C++ synchronisation constructs to POWER, including C/C++ spinlock mutexes, fences, and read-modify-write operations, together with the simpler atomic operations for which soundness is already known from our previous work; this is a first step in verifying concurrent algorithms that use load-reserve/store-conditional with respect to a realistic semantics. We also build confidence in the C/C++ model in its own terms, fixing some omissions and contributing to the C standards committee adoption of the C++11 concurrency model

    Mathematizing C++ concurrency

    Get PDF
    Shared-memory concurrency in C and C++ is pervasive in systems programming, but has long been poorly defined. This motivated an ongoing shared effort by the standards committees to specify concurrent behaviour in the next versions of both languages. They aim to provide strong guarantees for race-free programs, together with new (but subtle) relaxed-memory atomic primitives for high-performance concurrent code. However, the current draft standards, while the result of careful deliberation, are not yet clear and rigorous definitions, and harbour substantial problems in their details. In this paper we establish a mathematical (yet readable) semantics for C++ concurrency. We aim to capture the intent of the current (`Final Committee') Draft as closely as possible, but discuss changes that fix many of its problems. We prove that a proposed x86 implementation of the concurrency primitives is correct with respect to the x86-TSO model, and describe our Cppmem tool for exploring the semantics of examples, using code generated from our Isabelle/HOL definitions. Having already motivated changes to the draft standard, this work will aid discussion of any further changes, provide a correctness condition for compilers, and give a much-needed basis for analysis and verification of concurrent C and C++ programs

    Rust for Morello: Always-On Memory Safety, Even in Unsafe Code (Artifact)

    Get PDF

    Change in device-measured physical activity assessed in childhood and adolescence in relation to depressive symptoms: a general population-based cohort study

    Get PDF
    Aim: Evidence for a link between physical activity and mental health in young people is hampered by methodological shortcomings. Using repeat assessments of device-measured physical activity, we examined the association of within-individual variation in free-living activity over 7 years with depressive symptoms. Methods: This was a prospective cohort study of a nationally representative sample of children born in the UK (n=4898). Physical activity was quantified using accelerometry at ages 7 and 14. The main outcome was depressive symptoms, based on the Short Mood and Feelings Questionnaire, assessed at age 14. Results: After adjustment for socioeconomic status, body mass index and psychological problems at baseline, a higher level of light-intensity activity at age 7 in girls was associated with a lower likelihood of having depressive symptoms at follow-up (OR, 0.79; 95% CI 0.61 to 1.00), although no associations were observed for moderate to vigorous activity or sedentary behaviour. Girls who transitioned from low baseline activity to higher levels at follow-up experienced a lower risk of depressive symptoms (OR, 0.60; 95% CI 0.39 to 0.92) compared with the inactive reference category. Null associations were observed in boys. Participants who consistently met the current recommendation of 60 min/day of moderate to vigorous activity both at 7 and 14 years of age experienced the lowest risk of depressive symptoms (OR, 0.55; 95% CI 0.34 to 0.88). Conclusion: To prevent depressive symptoms in adolescence, policies to increase physical activity from mid-childhood may have utility

    Overhauling SC atomics in C11 and OpenCL

    Get PDF
    Despite the conceptual simplicity of sequential consistency (SC), the semantics of SC atomic operations and fences in the C11 and OpenCL memory models is subtle, leading to convoluted prose descriptions that translate to complex axiomatic formalisations. We conduct an overhaul of SC atomics in C11, reducing the associated axioms in both number and complexity. A consequence of our simplification is that the SC operations in an execution no longer need to be totally ordered. This relaxation enables, for the first time, efficient and exhaustive simulation of litmus tests that use SC atomics. We extend our improved C11 model to obtain the first rigorous memory model formalisation for OpenCL (which extends C11 with support for heterogeneous many-core programming). In the OpenCL setting, we refine the SC axioms still further to give a sensible semantics to SC operations that employ a ‘memory scope’ to restrict their visibility to specific threads. Our overhaul requires slight strengthenings of both the C11 and the OpenCL memory models, causing some behaviours to become disallowed. We argue that these strengthenings are natural, and that all of the formalised C11 and OpenCL compilation schemes of which we are aware (Power and x86 CPUs for C11, AMD GPUs for OpenCL) remain valid in our revised models. Using the HERD memory model simulator, we show that our overhaul leads to an exponential improvement in simulation time for C11 litmus tests compared with the original model, making exhaustive simulation competitive, time-wise, with the non-exhaustive CDSChecker tool

    Association of objectively measured physical activity with brain structure: UK Biobank study

    Get PDF
    Background Physical activity may be beneficial for cognition but mechanisms are unclear. We examined the association between objectively assessed physical activity and brain volume, with a focus on the hippocampus region. Methods We used data from UK Biobank (n=5,272; aged 55.4±7.5 yrs; 45.6% men) collected through 2013‐2016. Participants wore the Axivity AX3 wrist‐worn triaxial accelerometer for seven days to assess habitual physical activity. Structural magnetic resonance imaging was performed using a standard Siemens Skyra 3T running VD13A SP4 to obtain images of the brain. Results There was an association between physical activity (per SD increase) and grey matter volume after adjustment for a range of covariates, although this association was only detected in older adults (>60 yrs old). We also observed associations of physical activity with both left (B=0.52, 95% CI, 0.01, 1.03; p=0.046) and right hippocampal volume (B=0.59, 95% CI, 0.08, 1.10; p=0.024) in covariate adjusted models. Conclusion In summary, physical activity may play a role in the prevention of neurodegenerative diseases

    Obesity, metabolic health, and history of Cytomegalovirus infection in the general population

    Get PDF
    Context:Commoncommunity-acquired infections, such as cytomegalovirus (CMV),maycontribute to the development of obesity and metabolic dysfunction, but empirical evidence is scarce. Objective: We examined the associations between CMV, obesity and metabolic characteristics in a large, general population-based sample of adults. Design and setting: An observational study in community dwelling adults from the general population, ‘Understanding Society – the UK Household Longitudinal Study’. Participants: 9,517 men and women (aged 52.4 ± 16.4 yrs; 55.3% female). Measures: CMV infection was measured using Immunoglobulin G (IgG) from serum. Obesity was defined as body mass index ≥30 kg/m2. Based on blood pressure, HDL-cholesterol, triglycerides,glycated haemoglobin A1c, and C-reactive protein, participants were classified as ‘healthy’ (0 or 1 metabolic abnormality) or ‘unhealthy’ (≥2 metabolic abnormalities). Results: A positive CMV test was recorded in 47.5% of the sample. There was no association between CMV and obesity. Of the individual metabolic risk factors, CMV was positively associated with glycated haemoglobin and HDL-cholesterol. In combination, only ‘unhealthy non-obese’ participants had modestly increased odds of CMV (odds ratio compared to healthy normal weight = 1.12, 95% confidence interval 1.00 – 1.26) after adjusting for a range of variables. CMV was associated with an increased prevalence of cardiovascular diseases (odds ratio=1.67; 1.07 – 2.60) independently of obesity, metabolic risk factors, and other covariates. Conclusion: Our findings suggest a weak but statistically significant association between CMV and metabolic dysfunction in non-obese adults. This relationship appears to be masked in the obese, possibly by the effects of excess adiposity on metabolism
    • …
    corecore